import { NgModule } from '@angular/core';
import { FrameworkComponent } from './framework.component';
import { LrtmComponent } from './lrtm/lrtm.component';
import { StorageService } from '../shared/services/storage.service';
import { NavModule } from './navigation/navigation.module';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '../guards/auth.guard';
import { ModalModule } from '../shared/components/modal/modal.module';
import { TaskComponent } from './lrtm/task/task.component';
import { UtilsService } from '../shared/services/utils.service';

import { AccountModule } from './account/account.module';
import { LrtmService } from './lrtm/lrtm.service';
import { ScrollToTopComponent } from '../modules/research/company/shared/scrollToTop/scrollToTop.component';

const routes: Routes = [
    {
        path: '',
        component: FrameworkComponent,
        children: [
            {
                path: '',
                redirectTo: 'home',
                pathMatch: 'full'
            },
            {
                path: 'account',
                loadChildren: './account/account.module#AccountModule',
                canActivate: [AuthGuard]
            },
            {
                path: 'home',
                loadChildren: '../modules/home/home.module#HomeModule',
                data: { preload: true },
                canActivate: [AuthGuard]
            },
            {
                path: 'research',
                loadChildren: '../modules/research/research.module#ResearchModule',
                data: { preload: true, whenAuth: true },
                canActivate: [AuthGuard]
            },
            {
                path: 'tools',
                loadChildren: '../modules/reporting/reporting.module#ReportingModule',
                canActivate: [AuthGuard]
            },
            {
                path: 'portfolios',
                loadChildren: '../modules/portfolio/portfolio.module#PortfolioModule',
                canActivate: [AuthGuard]
            },
            {
                path: 'knowledge-center',
                loadChildren: '../modules/knowledge-center/knowledge-center.module#KnowledgeCenterModule',
                canActivate: [AuthGuard]
            }
        ]
    }
];

/**
 * Framework module
 *
 * Author: Sorin Spiru
 * Date: 13.01.2018
 */
@NgModule({
    providers: [
        StorageService,
        LrtmService,
        UtilsService
    ],
    imports: [
        CommonModule,
        NavModule,
        ModalModule,
        AccountModule,
        RouterModule.forChild(routes)
    ],
    declarations: [
        FrameworkComponent,
        LrtmComponent,
        TaskComponent,
        ScrollToTopComponent
    ],
    exports: [
        FrameworkComponent,
        ScrollToTopComponent
    ]
})
export class FrameworkModule { }
